package com.arelikebrothers.demo.concurrent.jdk;

import java.util.concurrent.locks.LockSupport;

/**
 * Created by lennon on 01/05/2017.
 */
public class LockSurpportDemo {
    public static Object u = new Object();

    public static class ChangeObjectT implements Runnable {


        @Override
        public void run() {
            synchronized (u) {
                System.out.println("in " + Thread.currentThread().getName());
                LockSupport.park();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new ChangeObjectT(), "T1");
        Thread t2 = new Thread(new ChangeObjectT(), "T2");

        t1.start();
        t2.start();

        LockSupport.unpark(t1);
        LockSupport.unpark(t2);

        t1.join();
        t2.join();
    }
}
